#include <iostream>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>

int main()
{
    pid_t id;
    id = fork();
    if (id == 0)
    {
        sleep(2);
        printf("hello world\n");
        printf("hello world\n");
        printf("hello world\n");
        raise(2);
        // int a = 10;
        // a /= 0;
        printf("hello world\n");
        exit(1);
    }

    int status = 0;
    waitpid(id, &status, 0);
    printf("signal: %d, exit code: %d, core dump: %d\n",
           (status & 0x7f), ((status >> 8) & 0xff), ((status >> 7) & 0x1));
    return 0;
}

// int main()
// {
//     printf("hello world\n");
//     printf("hello world\n");
//     printf("hello world\n");
//     printf("hello world\n");
//     int a = 10;
//     a = a / 0;
//     printf("hello world\n");
//     printf("hello world\n");
//     printf("hello world\n");
//     return 0;
// }